﻿/// JZ_06
/// 输入一个链表的头节点，从尾到头反过来返回每个节点的值（用数组返回）。
/// https://leetcode-cn.com/problems/cong-wei-dao-tou-da-yin-lian-biao-lcof/
using IListNode;
using System;
using System.Collections.Generic;

namespace _590_n_ary_tree_postorder_traversal
{
    class Program
    {
        static void Main (string[] args)
        {
            Console.WriteLine ("Hello World!");
        }
    }

    public class Solution
    {
        public IList<int> Postorder (Node root)
        {
            List<int> nums = new List<int> ();

            if (root == null) return nums;
            foreach (Node node in root.children)
            {
                nums.AddRange (Postorder (node));
            }
            nums.Add (root.val);
            return nums;
        }
    }
}
